using System;
using System.Runtime.InteropServices;

namespace SpoolFileLibrary.Reader.Winspool {
    [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
    [CLSCompliant(false)]
    public struct DEVMODE {
        public unsafe fixed char dmDeviceName [32];
        public ushort dmSpecVersion;
        public ushort dmDriverVersion;
        public ushort dmSize;
        public short dmDriverExtra;
        public uint dmFields;
        public short dmOrientation;
        public short dmPaperSize;
        public short dmPaperLength;
        public short dmPaperWidth;
        public short dmScale;
        public short dmCopies;
        public short dmDefaultSource;
        public short dmPrintQuality;
        public short dmColor;
        public short dmDuplex;
        public short dmYResolution;
        public short dmTTOption;
        public short dmCollate;
        public unsafe fixed char dmFormName [32];
        public ushort reserved0;
        public uint reserved1;
        public uint reserved2;
        public uint reserved3;
        public uint dmNup;
        public uint reserved4;
        public uint dmICMMethod;
        public uint dmICMIntent;
        public uint dmMediaType;
        public uint dmDitherType;
        public uint reserved5;
        public uint reserved6;
        public uint reserved7;
        public uint reserved8;

        public DEVMODE(byte[] data) {
            unsafe {
                fixed(byte* packet = &data[0]) {
                    this = *(DEVMODE*) packet;
                }
            }
        }
    }
}